package com.iotp.service.user_statistics;

import com.iotp.dao.user_statistics.UserStatisticsMapper;
import com.iotp.entity.user_statistics.UserStatistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;


@Service("/userStatistics")
public class UserStatisticsServiceImpl implements UserStatisticsService {

    @Autowired
    private UserStatisticsMapper userStatisticsMapper;

    @Override
    public int add(UserStatistics userStatistics) {
        userStatistics.setCreateTime(System.currentTimeMillis());
        return this.userStatisticsMapper.insert(userStatistics);
    }

    @Override
    public Long getAllUserNum() {
        return this.userStatisticsMapper.getAll();
    }

    @Override
    public Long getCurrentUserNum(Long startTime, Long endTime) {
        HashMap params = new HashMap();
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        return this.userStatisticsMapper.getByCondition(params);
    }

    @Override
    public Long getWeekUserNum(Long startTime, Long endTime) {
        HashMap params = new HashMap();
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        return this.userStatisticsMapper.getByCondition(params);
    }

    @Override
    public Long getMonthUserNum(Long startTime, Long endTime) {
        HashMap params = new HashMap();
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        return this.userStatisticsMapper.getByCondition(params);
    }
}
